<?php
/**
 * Created by PhpStorm.
 * User: l
 * Date: 2018/11/19
 * Time: 15:12
 */
use app\assets\AppAsset;
use app\common\CommonHelper;

$base = Yii::$app->request->baseUrl;
AppAsset::addCss($this,$base . '/app/css/vest-list.css');
AppAsset::addCss($this,$base . '/app/css/bar-detail.css?V=0.0.4');
AppAsset::addCss($this,$base . '/app/css/dynamic-detail.css?V=0.0.9');

AppAsset::addCss($this,$base . '/css/jquery.Jcrop.css');
AppAsset::addScript($this,$base . '/js/jquery.Jcrop.min.js');

$model = new CommonHelper();
$baseUrlHead  = $model->getIp();

?>
<div class="detail-container" style="width: 74rem">
    <p class="top-title">用户详情</p>

    <div style="float: left">
        <p class="item-title"><span class="necessary-note">*</span>用户名称</p>
        <input id="userName" class="input-row" value="<?= $user['user_nickname']?>" readonly>
    </div>

    <div class="clear"></div>

    <div style="float: left;">
        <p class="item-title"><span class="necessary-note">*</span>性别</p>
        <input id="userSex" class="input-row" value="<?= $user['user_sex']== 0 ?"女":"男"?>" readonly>
    </div>

    <div class="clear"></div>

    <div style="float: left;">
        <p class="item-title"><span class="necessary-note">*</span>城市</p>
        <input id="userCity" class="input-row" value="<?= $user['city_name'] != "%Null%" ? $user['city_name'] : "无" ?>" readonly>
    </div>

    <div class="clear"></div>

    <div style="float: left;">
        <p class="item-title"><span class="necessary-note">*</span>签名</p>
        <textarea id="userSign" style="color: #78797B; font-size: 14px; height: 80px; width: 320px; border-color: #efefef; resize: none; border-radius:5px" cols="30" rows="10" readonly><?= $user['user_sign'] != "%Null%" ?$user['user_sign']:"无签名"?></textarea>

    </div>

    <div class="clear"></div>

    <p class="item-title"><span class="necessary-note">*</span>头像</p>
    <div class="image-container">
        <div id="userIon" class="image-item">
            <?php if ($user['user_avatar']): ?>
                <img class="image-choose" src="<?= $user['user_avatar']?>">    
            <?php else: ?>
                <img class="image-choose" src="<?= $base?>/app/images/dynamic/default-logo.png">    
            <?php endif ?>
        </div>
    </div>

    <div class="clear"></div>

    <p class="item-title"><span class="necessary-note">*</span>相册（最多9张）</p>
    <div class="image-container" id="imageChoose">
        <input type="hidden" id="userPhotos" value="<?= $user['user_photos'] ?>">
    </div>
</div>

<script>
    (function (){
        var userPhotos = $('#userPhotos').val();

        if (userPhotos != '%Null%' && userPhotos != null) {
            var arr = userPhotos.split(';');
            console.log(arr);
            imgHTML = "";
            $.each(arr, function(k, v){
                imgHTML += '<div class="image-item"><img id="userPic" class="image-value" style="" src="'+ v +'" readonly></div>';
            });
            $("#imageChoose").append(imgHTML);
        } else {
            imgHTML ='<div class="image-item"><img id="userPic" class="image-value" src="<?= $base?>/app/images/dynamic/default-logo.png" readonly></div>';
            $("#imageChoose").append(imgHTML);
        }
    })();
</script>
